// custom-tab-bar/index.js
Component({
	data: {
		active: 0,
		list: [{
			pagePath: "/pages/home/home",
			text: "首页",
			iconPath: "wap-home-o",
			selectedIconPath: "wap-home-o"
		}, {
			pagePath: "/pages/category/category",
			text: "分类",
			iconPath: "apps-o",
			selectedIconPath: "apps-o"

		}, {
			pagePath: "/pages/topic/topic",
			text: "专题",
			iconPath: "point-gift-o",
			selectedIconPath: "point-gift-o"

		},
		{
			pagePath: "/pages/cart/cart",
			text: "购物车",
			iconPath: "cart-o",
			selectedIconPath: "cart-o"

		},
		{
			pagePath: "/pages/user/user",
			text: "我的",
			iconPath: "manager-o",
			selectedIconPath: "manager-o"

		}
		]
	},
	//组件的方法要放到methods中
	methods: {
		onChange(e) {
			console.log(e)
			let index = e.detail
			// event.detail 的值为当前选中项的索引
			this.setData({ active: index });
			//小程序切换页面
			wx.switchTab({
				url: this.data.list[index].pagePath,
			})
		},

	}

})